package cn.drew.house.service.impl;



import cn.drew.basic.utils.PageList;
import cn.drew.house.domain.ContractInformation;
import cn.drew.house.mapper.ContractInformationMapper;
import cn.drew.house.query.ContractInformationQuery;
import cn.drew.house.service.ContractInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Service
public class ContractInformationServiceImpl implements ContractInformationService {

    @Autowired
    private cn.drew.house.mapper.ContractInformationMapper contractInformationMapper;
    @Override
    public void add(ContractInformation ContractInformation) {
        contractInformationMapper.add(ContractInformation);
    }

    @Override
    public void update(ContractInformation ContractInformation) {
        contractInformationMapper.update(ContractInformation);
    }

    @Override
    public void delete(Long id) {
        contractInformationMapper.delete(id);
    }

    @Override
    public ContractInformation findById(Long id) {
        return contractInformationMapper.findById(id);
    }

    @Override
    public List<ContractInformation> findAll() {
        return contractInformationMapper.findAll();
    }



    @Override
    public PageList<ContractInformation> queryByPage(ContractInformationQuery contractInformationQuery) {
        Integer count = contractInformationMapper.queryByCount(contractInformationQuery);
        if (count == 0 || count == null){
            return new PageList(0,new ArrayList());
        }else{
            List<ContractInformation> contractInformations = contractInformationMapper.queryByPage(contractInformationQuery);
            return new PageList<ContractInformation>(count,contractInformations);
        }

    }

    @Override
    public void patchDelete(List<Long> ids) {
        contractInformationMapper.patchDelete(ids);
    }

    @Override
    public ContractInformation findByHouseid(Integer houseId) {
        ContractInformation con = contractInformationMapper.findByHouseid(houseId);
        return con;

    }
}
